package com.itheima.info.system.manager.service;

import com.itheima.info.system.manager.dao.IBaseStudentDao;
import com.itheima.info.system.manager.domain.Student;
import com.itheima.info.system.manager.factory.Factory;

import java.util.ArrayList;

public class StudentService implements IBaseStudentService {
    IBaseStudentDao studentDao = Factory.getStudentDao();


    @Override
    public void add(Student student) {
        studentDao.add(student);
    }

    @Override
    public void delete(String sid) {
        studentDao.delete(sid);
    }

    @Override
    public void updata(String sid, Student student) {
        studentDao.updata(sid, student);
    }

    @Override
    public ArrayList<Student> findAll() {
        return studentDao.findAll();
    }

    @Override
    public boolean isEmpty() {
        ArrayList<Student> students = studentDao.findAll();
        return students.size() == 0;
    }

    @Override
    public boolean isExist(String sid) {
        int index = studentDao.getIndexBySid(sid);
        return index != -1;
    }
}
